/* soivpstf.p - SALES ORDER HEADER INVOICE POST                         */
/* Copyright 1986-2004 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.4.3.3.3.1 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 7.2      LAST MODIFIED: 11/14/94   BY: rxm *FT54*          */
/* REVISION: 7.2      LAST MODIFIED: 03/13/95   BY: jxz *F0M3*          */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 10/29/98   BY: *N004* Steve Nugent */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* myb          */
/* REVISION: 9.1      LAST MODIFIED: 10/10/00   BY: *N0W8* Mudit Mehta  */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.4.3.3.3.1 $    BY: Somesh Jeswani        DATE: 06/29/04  ECO: *P27X*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
     {mfdeclre.i}
{cxcustom.i "SOIVPSTF.P"}
     define shared variable sonbr like so_nbr.
     define shared variable soline like sod_line.
     define shared variable soinv like so_inv_nbr.
     define shared variable eff_date like ar_date.
define shared variable undo_all like mfc_logic no-undo.
define shared variable using_seq_schedules like mfc_logical no-undo.
define shared temp-table so_shipper_info no-undo
   field tt_ship_id like tr_ship_id
   field tt_nbr like so_nbr
   field tt_line like sod_line
   field tt_inv_nbr like so_inv_nbr
   index tt_ship_id tt_nbr tt_line tt_inv_nbr.

define variable l_consigned_line_item like mfc_logical no-undo.

/* SALES ORDER CONSIGNMENT INVENTORY VARIABLES */
{socnvars.i}

/* CHECK TO SEE IF CONSIGNMENT IS ACTIVE */
{gprun.i ""gpmfc01.p""
   "(input ENABLE_CUSTOMER_CONSIGNMENT,
     input 10,
     input ADG,
     input CUST_CONSIGN_CTRL_TABLE,
     output using_cust_consignment)"}

do transaction on error undo, leave:

   {&SOIVPSTF-P-TAG1}
   for each tr_hist
      where tr_nbr   = sonbr
                 and tr_line = soline
                 and tr_type = "ISS-SO"
                 and tr_rmks = ""
   {&SOIVPSTF-P-TAG2}
                 use-index tr_nbr_eff:
   assign
      tr_rmks    = soinv
           tr_gl_date = eff_date.
      if using_cust_consignment
      then do:
         /* CHECK TO SEE IF LINE IS CONSIGNED. IF SO, THEN DISPLAY */
         /* A WARNING.                                             */
         l_consigned_line_item = no.
         {gprunmo.i &module  = "ACN"
                    &program = "socnsod1.p"
                    ?m   = """(input tr_nbr,
                                   input tr_line,
                                   output l_consigned_line_item,
                                   output consign_loc,
                                   output intrans_loc,
                                   output max_aging_days,
                                   output auto_replenish)"""}

         if l_consigned_line_item
         then do:
            {gprunmo.i &module  = "ACN"
                       &program = "socncuup.p"
                       ?m   = """(input tr_trnbr,
                                      input soinv)"""}
         end.  /* IF l_consigned_line_item */
      end.  /* IF using_cust_consignment */

      if using_seq_schedules
      then do:
         create so_shipper_info.

         assign
            tt_ship_id = "s" + tr_ship_id
            tt_nbr     = tr_nbr
            tt_line    = tr_line
            tt_inv_nbr = soinv.

         if recid(so_shipper_info) = -1
         then .
      end. /* IF using_seq_schedule */
   end. /* FOR EACH tr_hist */
   return.
end. /* do transaction */
undo_all = yes.
